<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--
  Created by IntelliJ IDEA.
  User: legion
  Date: 2021/10/18
  Time: 9:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>修改</title>
    <script type="text/javascript" src="/resource/js/jquery-3.2.1.js"></script>
    <link rel="stylesheet" href="/resource/css/index3.css">
</head>
<body>
<h1>修改页面</h1>
<form >
    <input type="hidden" name="gid" value="${byId.gid}">
    <input type="hidden" name="gtime" value="<fmt:formatDate value="${byId.gtime}" pattern="yyyy-MM-dd"></fmt:formatDate>">
   商品名称:<input type="text" name="gname" value="${byId.gname}"><br>
    商品价格:<input type="text" name="gprice" value="${byId.gprice}"><br>
    商品品牌:<select name="tid">
    <option value="">--请选择--</option>
    <c:forEach items="${gtype}" var="g">
        <option value="${g.tid}" ${g.tid==byId.tid?'selected':''}>${g.tname}</option>
    </c:forEach>
</select>    <br>
    <input type="button" value="提交" onclick="update()">

</form>
<script>
    function update() {
        $.post("update",$("form").serialize(),function (result) {
            if (result){
                alert("保存成功")
                location="list"
            }else {
                alert("保存失败")
            }
        })
    }
</script>
</body>
</html>
